import { request,requestOther } from '@/utils/request';

import type { chatMessageRequest, chatResponse } from '@/api/model/chatModel';

const Api = {
  Conversation:'https://api.rs888.net/api/chat/conversation',
  Msg:'https://api.rs888.net/api/chat/msg',
  Retrieve:'https://api.rs888.net/api/chat/retrieve',
  MessageList:'https://api.rs888.net/api/chat/message/list',
  CreateChat: 'https://api.rs888.net/api/chat/create',
};

export function conversation(d:any)
{
  let apiToken=localStorage.getItem('api.token')
  requestOther.setHeader({'token':apiToken})

  return requestOther.post<object>({
    url: Api.Conversation,
    data: d
  });
}
//向AI发消息
export function sendMsg(d:any)
{
  let apiToken=localStorage.getItem('api.token')
    requestOther.setHeader({'token':apiToken})
  return requestOther.post<object>({
    url: Api.Msg,
    data: d
  });
}
//查看会话详情
export function Retry(d:any)
{
  let apiToken=localStorage.getItem('api.token')
    requestOther.setHeader({'token':apiToken})
  return requestOther.post<object>({
    url: Api.Retrieve,
    data: d
  });
}
//查看会话消息详情
export function MessageList(d:any)
{
  let apiToken=localStorage.getItem('api.token')
   requestOther.setHeader({'token':apiToken})
  return requestOther.post<object>({
    url: Api.MessageList,
    data: d
  });
}










//创建会话
export function createChat(model : chatMessageRequest) {
  return request.post<chatResponse>({
    url: Api.CreateChat,
    data: model
  });
}
